package com.stylefeng.guns.rest.modular.artitle.service;

import com.baomidou.mybatisplus.mapper.Condition;
import com.stylefeng.guns.rest.common.persistence.dao.FileEntityMapper;
import com.stylefeng.guns.rest.common.persistence.model.Article;
import com.stylefeng.guns.rest.common.persistence.model.FileEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by ASUS-PC on 2018/8/10.
 */
@Service
public class FileService {
    @Autowired
    private FileEntityMapper fileEntityMapper;

    public boolean insertFile(FileEntity fileEntity){
        return fileEntityMapper.insert(fileEntity)==1 ?true:false;
    }

    public FileEntity searchById(int fileId){
        List<FileEntity> list = fileEntityMapper.selectList(Condition.create().eq("id" ,fileId));
        if(list!=null && list.size()>0){
            return list.get(0);
        }else {
            return null;
        }
    }
}
